package com.mz.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mz.common.dto.PaginationVo;
import com.mz.common.dto.R;
import com.mz.common.utils.PageDataHandlerUtils;
import com.mz.entity.SmsVersion;
import com.mz.entity.vo.CurVersionVo;
import com.mz.entity.vo.VersionInfoVo;
import com.mz.service.SmsVersionService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (SmsVersion)表控制层
 *
 * @author makejava
 * @since 2023-12-13 13:38:33
 */
@RestController
@RequestMapping("/smsVersion")
public class SmsVersionController  {
    /**
     * 服务对象
     */
    @Resource
    private SmsVersionService smsVersionService;

    /**
     * 分页查询所有数据
     * @return 所有数据
     */
    @GetMapping("/pagination")
    public R getVersionPagination(PaginationVo paginationVo) throws Exception {
        IPage page = smsVersionService.getVersionPagination(paginationVo);
        return PageDataHandlerUtils.toR(page);
    }

    @PostMapping("")
    public R addVersionInfo(@RequestBody VersionInfoVo versionInfo) throws Exception {
        smsVersionService.addVersionInfo(versionInfo);
        return R.ok();
    }
    /**
     * 修改数据
     * @return 修改结果
     */
    @PutMapping("/isCur")
    public R updateCurOnlineVersion(@RequestBody CurVersionVo curVersionVo ) throws Exception  {
        smsVersionService.updateVersionInfo(curVersionVo);
        return R.ok();
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @PostMapping("/remove")
    public R removeVersionInfo(@RequestBody List<Long> idList) throws Exception {
        smsVersionService.removeVersionInfo(idList);
        return R.ok();
    }
}

